import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { UsersComponent } from './users/users.component';
import { UserAddComponent } from './users/user-add/user-add.component'
import { RolesComponent } from './roles/roles.component';
import { RoleAddComponent } from './roles/role-add/role-add.component';
import { RoleListComponent } from './roles/role-list/role-list.component'
import { PostComponent } from './post/post.component';
import { PostAddComponent } from './post/post-add/post-add.component'

const routes: Routes = [
  {
     path: '', 
     redirectTo: '/', 
     pathMatch: 'full' },
  //用户管理的路由
  { 
    path: 'user', 
    children:[
    {
      path: 'userList',   //全部用户的路由
      component: UsersComponent  
    },
    {
      path: 'userAdd',    //用户增加的路由
      component: UserAddComponent
    }
]
},
  //角色管理的路由
  { 
    path: 'role', 
    children: [
      {
        path: 'roleAdd',   //角色增加的路由
        component: RoleAddComponent
      },
      {
        path: 'roleList',  //全部角色的路由
        component: RoleListComponent 
      }
  ]
  },
  //文章管理的路由
  { 
    path: 'post', 
    children:[
    {
      path: 'postList',  //全部文章的路由
      component: PostComponent,
    },
    {
      path: 'postAdd',   //文章增加的路由
      component: PostAddComponent
    }
]
}
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  exports: [ RouterModule ],
  declarations: []
})
export class AppRoutingModule { }
